package com.example.demo.huawei;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

/*
4
cat
bt
hat
tree
atach??

输出:3

 */
public class OD40 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        List<String> words = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            words.add(sc.nextLine());
        }
        String chars = sc.nextLine();

        //        System.out.println(words);
        //        System.out.println(chars);
        System.out.println(sum(words, chars));
    }

    private static int sum(List<String> words, String chars) {
        Map<Character, Integer> charsMap = countMap(chars);
        //        System.out.println(charsMap);
        int count = 0;
        for (String word : words) {
            Map<Character, Integer> wordMap = countMap(word);
            if (check(charsMap, wordMap)) {
                count++;
            }
        }
        return count;
    }

    private static boolean check(Map<Character, Integer> charsMap, Map<Character, Integer> wordMap) {
        int diff = 0;
        for (Map.Entry<Character, Integer> entry : wordMap.entrySet()) {
            if (!charsMap.containsKey(entry.getKey())) {
                diff += entry.getValue();
            } else if (charsMap.get(entry.getKey()) - entry.getValue() < 0) {
                diff += entry.getValue() - charsMap.get(entry.getKey());
            }
        }
        return diff <= (charsMap.get('?') == null ? 0 : charsMap.get('?'));
    }

    private static Map<Character, Integer> countMap(String chars) {
        Map<Character, Integer> charsMap = new HashMap<>();
        for (char c : chars.toCharArray()) {
            charsMap.put(c, charsMap.getOrDefault(c, 0) + 1);
        }
        return charsMap;
    }
}
